using System.Collections;
using UnityEngine;

public class SmokeSteamManager : MonoBehaviour
{
	public WheelJoint2D wheel2D;

	public ParticleSystem parS;

	public Transform transCheck;

	private LayerMask maskGround;

	private bool enablePars;

	private void Awake()
	{
		maskGround = LayerMask.NameToLayer("GROUND");
		parS.Stop();
	}

	private void Update()
	{
		if ((bool)Physics2D.Raycast(transCheck.position, Vector2.down, 0.25f, 1 << (int)maskGround))
		{
			if (wheel2D != null)
			{
				if (wheel2D.jointSpeed > 10f && !parS.isPlaying)
				{
					parS.Clear();
					parS.Play();
				}
			}
			else if (parS.isPlaying)
			{
				parS.Stop();
			}
		}
		else if (!enablePars)
		{
			enablePars = true;
			parS.transform.SetParent(null);
			StartCoroutine(delay_());
		}
	}

	private IEnumerator delay_()
	{
		yield return new WaitForSecondsRealtime(1f);
		parS.gameObject.SetActive(value: false);
	}
}
